package p.sglmsn.top.apale;

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;

import java.io.IOException;

public class HelloApplication extends Application {
    private ImageTabController imageTabController;
    private EncryptTabController encryptTabController;
    private DecryptTabController decryptTabController;

    @Override
    public void start(Stage stage) throws IOException {
        // 创建主布局容器，横向排列
        HBox mainBox = new HBox(10); // 10为间距

        // 加载三个功能模块
        FXMLLoader imageLoader = new FXMLLoader(getClass().getResource("image-tab.fxml"));
        VBox imageBox = imageLoader.load();
        imageTabController = imageLoader.getController();

        FXMLLoader encryptLoader = new FXMLLoader(getClass().getResource("encrypt-tab.fxml"));
        VBox encryptBox = encryptLoader.load();
        encryptTabController = encryptLoader.getController();

        FXMLLoader decryptLoader = new FXMLLoader(getClass().getResource("decrypt-tab.fxml"));
        VBox decryptBox = decryptLoader.load();
        decryptTabController = decryptLoader.getController();

        // 设置最小宽度和边框样式，符合用户偏好
        imageBox.setMinWidth(300);
        imageBox.setStyle("-fx-border-color: gray; -fx-border-width: 1px; -fx-padding: 10;");
        
        encryptBox.setMinWidth(300);
        encryptBox.setStyle("-fx-border-color: gray; -fx-border-width: 1px; -fx-padding: 10;");
        
        decryptBox.setMinWidth(300);
        decryptBox.setStyle("-fx-border-color: gray; -fx-border-width: 1px; -fx-padding: 10;");

        // 添加到主容器
        mainBox.getChildren().addAll(imageBox, encryptBox, decryptBox);

        Scene scene = new Scene(mainBox, 1000, 500);
        stage.setTitle("图片与文件处理工具");
        stage.setScene(scene);
        stage.setUserData(this); // 保存控制器引用
        stage.show();
    }

    public ImageTabController getImageTabController() {
        return imageTabController;
    }

    public EncryptTabController getEncryptTabController() {
        return encryptTabController;
    }

    public DecryptTabController getDecryptTabController() {
        return decryptTabController;
    }

    public static void main(String[] args) {
        launch();
    }
}